package gr.handmademarket.ui.tabs;

import gr.handmademarket.po.enums.SellerTabType;
import gr.handmademarket.po.implementations.Seller;
import gr.handmademarket.ui.panels.SellerProductsPanel;
import gr.handmademarket.ui.panels.SellerProfilePanel;

import org.apache.wicket.extensions.markup.html.tabs.AbstractTab;
import org.apache.wicket.markup.html.panel.EmptyPanel;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

/**
 * seller tab.
 */
public class SellerTab 
extends AbstractTab{

	/**
	 * serialVersionUID.
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * the local seller.
	 */
	private Seller seller;
	
	private SellerTabType type;
	
	public void setType(SellerTabType type) {
		this.type = type;
	}

	/**
	 * Creates a new SellerTab object. 
	 * @param sellerModel 
	 *
	 */
	public SellerTab(IModel<Seller> sellerModel, SellerTabType type) {
		super(new Model<String>(type.toString()));
		this.type = type;
		this.seller = sellerModel.getObject();
	}

	@Override
	public Panel getPanel(String panelId) {
		if (SellerTabType.SHOP_OWNER_PROFILE.equals(type)){
			return new SellerProfilePanel(panelId,new CompoundPropertyModel<Seller>(seller));
		} else if (SellerTabType.SHOP_OWNER_CAROUSEL.equals(type)){
			return new EmptyPanel(panelId);
		} else if (SellerTabType.SHOP_OWNER_PRODUCTS.equals(type)){
			return new SellerProductsPanel(panelId,new CompoundPropertyModel<Seller>(seller));
		}
		return new EmptyPanel(panelId);
	}	
}
